import {Store,Module,ActionContext} from 'vuex'
import Ajax from '../../lib/ajax'

interface SettingState{
    loading:Boolean;
    settings:Object;
}
class SettingMutations{

}
class SettingModule {
    namespaced=true;
    state={
        loading: false,
        settings: {
            commodityWares: [],
            commodityClasses: [],
            areas: [],
            shippingTemplates: [],
            memberFormItems: [],
            memberLevels: [],
            commodityGuarantees: [],
            ship: {
                shippintTemplateType: 0
            },
            xp: {

            },
            payment: {
                bankInfos: []
            }
        }
    }
    actions={
        async getAllSettings(context:ActionContext<SettingState,any>){
            context.state.loading=true;
            let reponse = await Ajax.get('/api/services/app/Setting/GetAllSettings');
            context.state.settings = reponse.data.result;
            context.state.loading = false;
            console.log(context.state.settings);
        },
    };
    mutations={
        setShipSetting(state, value){
            state.settings.ship = Object.assign({}, value);
        },
    }
}
const settingModule=new SettingModule();
export default settingModule;